package com.jrx.anytxn.param.controller.aviator;

import com.google.common.collect.Maps;
import com.jrx.anytxn.i18n.annotation.IgnoreConvertField;
import com.jrx.anytxn.i18n.response.TxnRespResult;
import com.jrx.anytxn.common.exception.TxnException;
import com.jrx.anytxn.param.dto.aviator.AviatorRuleSetTypeRes;
import com.jrx.anytxn.param.service.aviator.IAviatorRuleSetTypeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import jrx.auth.filter.service.InfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.List;

/**
 * 规则集的的管理
 *
 * @author Qingyao Xing
 * @date 2019/7/17 10:36
 */
@Api(tags = "规则集的的管理")
@RestController
@RequestMapping("/param/rule/set/type")
public class AviatorRuleSetTypeController {

    @Autowired
    private IAviatorRuleSetTypeService aviatorRuleSetTypeService;

    @Autowired
    private InfoService infoService;

    @ApiOperation(value = "用于下拉规则集列表的查询", notes = "用于下拉规则集列表的查询")
    @GetMapping(value = "/selectList/{param}")
    @IgnoreConvertField
    public TxnRespResult<HashMap<String, List<AviatorRuleSetTypeRes>>> getRuleSetType(@PathVariable String param) throws TxnException {
        TxnRespResult<HashMap<String, List<AviatorRuleSetTypeRes>>> result = new TxnRespResult<>();
        String tenantId= String.valueOf(infoService.getUser().getProjectId());
        List<AviatorRuleSetTypeRes> select = aviatorRuleSetTypeService.getAviatorRuleSetType(param,tenantId);
        HashMap<String, List<AviatorRuleSetTypeRes>> sysCodeMap = Maps.newHashMap();
        sysCodeMap.put("listData", select);
        return result.getSuccess(sysCodeMap);
    }

}
